﻿function createAreaTr(len) {
    len = parseInt(len);
    var hasLen = $("#tbArea tr").length;
    var str;
    var id;
    if (hasLen < len + 1) {
        for (var i = 0; i < len - hasLen + 1; i++) {
            id = $("#tbArea tr").length;

            str = "<tr><td>" + id + ".";
            str += "</td><td><input type='text' style='width: 40px' name='txtAreaBeginX" + id + "' class='int_txt' value='0' onkeyup='IsNumeric(this)' />";
            str += "</td><td> <input type='text' style='width: 40px' name='txtAreaBeginY" + id + "' class='int_txt' value='0' onkeyup='IsNumeric(this)'/>";
            str += "</td><td><input type='text' style='width: 40px' name='txtAreaWidth" + id + "' class='int_txt' value='0' onkeyup='IsNumeric(this)'/>";
            str += "</td><td><input type='text' style='width: 40px' name='txtAreaHeight" + id + "' class='int_txt' value='0' onkeyup='IsNumeric(this)'/>";
            str += "</td><td><select name='dropState" + id + "' style='width:50px'><option value='1'>启用</option><option value='0'>停用</option></select></td></tr>";
            $("#tbArea").append(str);
        }
    }
    else {
        if (confirm('所选的分区减少后，多出的分区将减少，确认删除？')) {
            for (var i = hasLen - 1; i > len; i--) {
                $("#tbArea tr").eq(i).remove();
            }
        }
    }
}
function createLightTr(len) {
    len = parseInt(len);
    var hasLen = $("#tbLight tr").length ;
    var str;
    var id;
 
    if (hasLen < len + 1) {
        for (var i = 0; i < len - hasLen + 1; i++) {
            id = $("#tbLight tr").length;
            str = "<tr><td>" + id + ".</td>";
            str += "<td><input type='text' style='width: 80px' class='Wdate'  onfocus=\"WdatePicker({dateFmt:'HH:mm:ss'})\" name='txtTimeBegin" + id + "' /></td>";
            str += "<td><input type='text' style='width: 40px' name='txtLightType" + id + "'  onkeyup='IsNumeric(this)' /></td>";
            str += "<td><input type='text' style='width: 40px' name='txtContent" + id + "' /></td></tr>";
            $("#tbLight").append(str);
        }
    }
    else {
        if (confirm('所选的分区减少后，多出的亮度将减少，确认删除？')) {
            for (var i = hasLen-1 ; i > len ; i--) {
                $("#tbLight tr").eq(i).remove();
            }
        }
    }
}